<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <title>缴费</title>
    <!-- 引入 WeUI -->
    <link rel="stylesheet" href="http://jxt.anan365.com/jiaofei/Public/weui-1.1.2/dist/style/weui.css"/>
    <script src="http://jxt.anan365.com/jiaofei/Public/jquery.js"></script>
</head>
<body ontouchstart>
<div class="page__hd">
    <h1 class="page__title" style="text-align: center;font-size: 18px;margin-top:20px">家校通缴费</h1>
</div>
<form action="http://jxt.anan365.com/jiaofei/index.php/Home/Index/qrpay" method="post">
<div class="page__bd">
    <div class="weui-cells__title">请选择学校和班级</div>
    <div class="weui-cells">
        <div class="weui-cell weui-cell_select weui-cell_select-after">
            <div class="weui-cell__hd">
                <label  class="weui-label">学校名称</label>
            </div>
            <div class="weui-cell__bd">
                <select class="weui-select" name="school" id="school">
                    <option value="0" style="display:none"></option>
                    <?php foreach($school as $k=>$v){ ?>
                    <option value="<?php echo $v['FId'].'__'.$v['FName'];?>"><?php echo $v['FName'];?></option>
                    <?php } ?>
                </select>
            </div>
        </div>
        <div class="weui-cell weui-cell_select weui-cell_select-after">
            <div class="weui-cell__hd">
                <label  class="weui-label">班级</label>
            </div>
            <div class="weui-cell__bd  banji">
                <select class="weui-select" name="class" id="class">
                </select>
            </div>
        </div>
    </div>
    <input type="hidden" name="openid" value="<?php echo $openid;?>">
    <div class="weui-cells__title">请输入学生名和联系方式</div>
    <div class="weui-cell">
        <div class="weui-cell__hd">
            <label class="weui-label">学生(名字)</label>
        </div>
        <div class="weui-cell__bd">
            <input class="weui-input" type="text" id="xs" name="student"  placeholder="请输入学生(名字)"/>
        </div>
    </div>
    <div class="weui-cell ">
        <div class="weui-cell__hd">
            <label class="weui-label">联系电话</label>
        </div>
        <div class="weui-cell__bd">
            <input class="weui-input" type="number" id="tel" name="phone" placeholder="请输入联系电话"/>
        </div>
    </div>
    <hr style="margin-left:17px;border:1px solid #F1F1EF">
    <div class="weui-cells__title">请选择或者输入缴费金额--(测试)</div>
    <div class="weui-cells weui-cells_radio">
        <label class="weui-cell weui-check__label money" for="x11">
            <div class="weui-cell__bd">
                <p>60元</p>
            </div>
            <div class="weui-cell__ft">
                <input type="radio" class="weui-check" name="radio_money" id="x11" value="60" checked="checked"/>
                <span class="weui-icon-checked"></span>
            </div>
        </label>
        <label class="weui-cell weui-check__label zdy" for="x13">
            <div class="weui-cell__bd">
                <p>自定义</p>
            </div>
            <div class="weui-cell__ft">
                <input type="radio" class="weui-check" name="radio_money" value="1" id="x13"/>
                <span class="weui-icon-checked"></span>
            </div>
        </label>
    </div>
    <div class="weui-cell zdy_money" style="display:none">
        <div class="weui-cell__hd">
            <label class="weui-label">缴费金额</label>
        </div>
        <div class="weui-cell__bd">
            <input class="weui-input" type="number" name="zdy_money" placeholder="请输入缴费金额(元)"/>
        </div>
    </div>
    <div class="weui-btn-area">
        <a class="weui-btn weui-btn_primary" href="javascript:" id="showTooltips">确定</a>
    </div>
</div>
</form>
</body>
</html>
<script>
    //选择学校获取班级
    $('#school').change(function(){
        var val = $(this).val();
        var arr = val.split('__');
        var fid = arr[0];
        if(fid){
            var url = "__CONTROLLER__/get_banji/fid/"+fid;
            $.get(url,function(e){
                //console.log(e);return false;
                if(e.code==0){
                    var html = '<select class="weui-select" name="class" id="class"><option value="0" style="display:none"></option>';
                    $(e.list).each(function(k,v){
                        html += '<option value="'+v.FId+'__'+v.FName+'">'+v.FName+'</option>';
                    })
                    $('.banji').html(html);
                }else{
                    alert(e.msg);
                }
            })
        }

    });

    //选择金额
    $(':radio').click(function(){
        var val = $(this).val();
        if(val == 1){
            $('.zdy_money').show();
        }else{
            $('.zdy_money').hide();
        }

    });
    //提交表单
    $('#showTooltips').click(function(){
        //验证数据
        var school = $('#school').val();
        var bj = $('#class').val();
        var xs = $('#xs').val();
        var tel = $('#tel').val();
        if(school==0 || !school){
            alert('请选择学校');
            return false;
        }
        //alert(bj);
        if(bj==0 || !bj){
            alert('请选择班级');
            return false;
        }
        if(!xs){
            alert('请输入学生名字');
            return false;
        }
        if(!tel){
            alert('请输入联系电话');
            return false;
        }
        var radio_val = $('input[name="radio_money"]:checked').val();

        if(radio_val == 1){
            var z_val = $('input[name=zdy_money]').val();
            if(z_val==0 || !z_val){
                alert('请输入自定义金额');
                return false;
            }
        }


        $('form').submit();
    });

    //验证数据

</script>
